﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Watson.Core.Tools;
using ITOMMS.Entity;
using ITOMMS.Business;

namespace ITOMMS.Web.InsideManage
{
    public partial class WorkLogView : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                DropDownListHelper.InitDropList<tbDepartmentEntity>(new tbDepartmentEntity().GetAll(), ddl部门, "ID", "DepartmentName");


                if (Request.Params["vid"] != null)
                {
                    string sid = Request.Params["vid"].ToString();


                    int pid = 0;
                    if (int.TryParse(sid, out pid))
                    {
                        DataShow(pid);
                    }
                }
            }
        }


        private void DataShow(int troubleId)
        {

            Vw工作日志视图Entity entity = new Vw工作日志视图Entity();
            entity = entity.FindEntity("ID=" + troubleId);

            if (entity != null)
            {
                ViewState["Entity"] = entity;
                txt姓名.Text = entity.RealName;
                ddl部门.SelectedValue = entity.部门.ToString();
                txt职位.Text = entity.职位;
                if (entity.日期.HasValue)
                {
                    txt日期.Text = entity.日期.Value.ToShortDateString();
                }
                List<Vw工作日志视图Entity> workList = new List<Vw工作日志视图Entity>();
                if (entity.日期.HasValue)
                    workList = entity.GetAllByQuery("日期='" + entity.日期.Value.ToShortDateString() + "' and RealName='" + entity.RealName + "'");
                //else
                 //   workList = entity.GetAllByQuery("RealName='" + entity.RealName + "'");
              
                DataList1.DataSource = workList;
                DataList1.DataBind();
            }
        }

        public string GetSatatus(string param)
        {
            string result = Enum.GetName(typeof(PubEnums.JinjiState), int.Parse(param));

            return result;
        }

        public string GetWorkType(string param)
        {
            string result = Enum.GetName(typeof(PubEnums.WorkType), int.Parse(param));

            return result;
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            Response.Redirect("WorkLogList.aspx", true);
        }

    }
}
